<%@ page import="com.gmono.managers.User" %>
<%@ page import="com.gmono.managers.UserManager" %><%--
  Created by IntelliJ IDEA.
  User: gaozijian
  Date: 2018/12/31
  Time: 18:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    request.setCharacterEncoding("UTF-8");
    User u=new User();
    u.setUsername(request.getParameter("username"));
    String err=null;
    if(!u.isExists())
    {
        u.setPhonenumber(request.getParameter("usertel"));
        u.setName(request.getParameter("truename"));


        String p = request.getParameter("password");
        String np = request.getParameter("new_password");

        try {
            assert p.equals(np) : "错误，重复密码不一致";
        } catch (AssertionError e) {
            err = e.getMessage();
        }
        u.setPassword(p);

        if(!UserManager.addUser(u)) err="错误，添加失败";
    }else err="用户已存在";

    if(err==null) err="成功";

%>

<script>
    alert('<%=err%>');
    self.location=document.referrer;
</script>


